package com.huage_06.lesson_04;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class HashMapDemo {
    public static void main(String[] args) {

        Map<String,String> map = new HashMap<String,String>();

        map.put("cardId","001");
        map.put("amount","Lisa");
        map.put("kind","gold");

        //遍历方式一 键找值
        Set<String> keySet = map.keySet();
        for (String key : keySet){
            String value = map.get(key);
            System.out.println(key+":" + value);
        }
        System.out.println("--------");
        //遍历方式二 键值对对象找键和值
        Set<Map.Entry<String, String>> set = map.entrySet();
        for(Map.Entry<String,String> e : set){
            String key = e.getKey();
            String value = e.getValue();
            System.out.println(key+":" + value);
        }

    }
}
